package com.jintoufs.util;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class BankCrawl {
    public Map<String,String> crawl() throws IOException {
        Document document = Jsoup.connect("http://ab.alipay.com/i/yinhang.htm").get();
        Elements icons = document.body().getElementsByClass("icon");
        Map<String, String> bank = new HashMap<>();
        for (Element icon: icons) {
            if (icon.className().split(" ").length > 1) {
                bank.put(icon.className().split(" ")[1], icon.text());
            }
        }
        return bank;
    }
}
